package com.digitalchina.lxnsy.activity.ecardConsult;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.entity.EcardConsultVO;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.lzy.ninegrid.ImageInfo;
import com.lzy.ninegrid.NineGridView;
import com.lzy.ninegrid.preview.NineGridViewClickAdapter;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

public class EcardConsultDetailsActivity extends BaseActivity {

    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_phone)
    TextView tvPhone;
    @Bind(R.id.tv_time)
    TextView tvTime;
    @Bind(R.id.nineGrid)
    NineGridView nineGrid;
    @Bind(R.id.tv_reply)
    TextView tvReply;
    @Bind(R.id.tv_name)
    TextView tvName;
    @Bind(R.id.tv_rep_time)
    TextView tvRepTime;
    @Bind(R.id.nineGrid_rep)
    NineGridView nineGridRep;

    private EcardConsultVO data;

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_ecard_consult_details);
    }

    @Override
    public void initMember() {

        data = (EcardConsultVO) getIntent().getSerializableExtra("vo");

        tvPhone.setText(data.getConsultUserPhone());
        tvTime.setText(data.getCreateTime());
        tvTitle.setText(data.getQuestionContent());


        ArrayList<ImageInfo> imageInfo = new ArrayList<>();
        if (data.getConsultImgList() != null && data.getConsultImgList().size() > 0) {
            nineGrid.setVisibility(View.VISIBLE);
            for (int i = 0; i < data.getConsultImgList().size(); i++) {
                ImageInfo info = new ImageInfo();
                info.setThumbnailUrl(data.getConsultImgList().get(i).getImgId());
                info.setBigImageUrl(data.getConsultImgList().get(i).getImgId());
                imageInfo.add(info);
            }
        } else {
            nineGrid.setVisibility(View.GONE);
        }

        nineGrid.setAdapter(new NineGridViewClickAdapter(activity, imageInfo));


        if(!StringUtil.isStrEmpty(data.getReplyTime())){

            tvName.setText(data.getExpertName());
            tvRepTime.setText(data.getReplyTime());
            tvReply.setText(data.getReplyContent());


            ArrayList<ImageInfo> imageInfo1 = new ArrayList<>();
            if (data.getReplyImgList() != null && data.getReplyImgList().size() > 0) {
                nineGridRep.setVisibility(View.VISIBLE);
                for (int i = 0; i < data.getReplyImgList().size(); i++) {
                    ImageInfo info = new ImageInfo();
                    info.setThumbnailUrl(data.getReplyImgList().get(i).getImgId());
                    info.setBigImageUrl(data.getReplyImgList().get(i).getImgId());
                    imageInfo1.add(info);
                }
            } else {
                nineGridRep.setVisibility(View.GONE);
            }

            nineGridRep.setAdapter(new NineGridViewClickAdapter(activity, imageInfo1));
        }


    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
